using System.Collections.Generic;

namespace SalaryReport.Core
{
    /// <summary>
    /// Static 	class to work with a set of tasks.
    /// </summary>
    public static class Worker
    {
        static List<SalaryInfo> list = new List<SalaryInfo>();
        static int _current = 0;

        /// <summary>
        /// Property that determine whether the latest element in the list of tasks.
        /// </summary>
        public static bool IsLast
        {
            get
            {
                lock (typeof(Worker))
                {
                    return _current >= list.Count;
                }
            }
        }

        /// <summary>
        /// Property that determine whether the current element in the list.
        /// </summary>
        public static int Current
        {
            get
            {
                lock (typeof(Worker))
                {
                    return _current;
                }
            }
            set
            {
                lock (typeof(Worker))
                {
                    _current = value;
                }
            }
        }

        /// <summary>
        /// Property that return the next value from the list.
        /// </summary>
        public static SalaryInfo Next
        {
            get
            {
                lock (typeof(Worker))
                {
                    SalaryInfo cur = list[_current];
                    _current++;
                    return cur;
                }
            }
        }

        /// <summary>
        /// List of the tasks.
        /// </summary>
        public static List<SalaryInfo> Reports
        {
            get
            {
                return list;
            }
            set
            {
                list = value;
            }
        }
    }
}
